package sso.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import sso.pojo.SysUser;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from sys_user where username=#{username}")
    SysUser selectUserByUsername(@Param("username") String username);

    @Select("SELECT m.permission \n" +
            "FROM sys_user u LEFT JOIN sys_user_role ur ON u.id=ur.user_id\n" +
            "LEFT JOIN sys_role_menu rm ON ur.role_id=rm.role_id\n" +
            "LEFT JOIN sys_menu m ON rm.menu_id=m.id\n" +
            "WHERE u.id=#{id}")
    List<String> selectUserPermissions(@Param("id") Integer id);
}
